$("#submit").click(function (){
    var data = $('#login').serialize()
    $.ajax({
        cache: true,
        type: "POST",
        contentType: "application/x-www-form-urlencoded; charset=utf-8",
        url:"/ajax/login",
        data:data,// 你的formid
        async: false,
        error: function(rs) {
            alert("Connection error");
        },
        success: function(rs) {
            if(rs.code == 0){
                window.location.href="/index"
            }else{
                alert(rs.data);
            }
        }
    });
})